package com.zx.base.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

public class LoadMoreListViewWithProgress extends RelativeLayout {

	private LoadMoreListView listView;
	private ProgressBar bar;

	public LoadMoreListViewWithProgress(Context context) {
		super(context);
		init(context);
	}

	public LoadMoreListViewWithProgress(Context context, AttributeSet set) {
		super(context, set);
		init(context);
	}

	private void init(Context context) {
		listView = new LoadMoreListView(context);
		bar = new ProgressBar(context);

		LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT);
		lp.addRule(RelativeLayout.CENTER_IN_PARENT);
		this.addView(bar, lp);

		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.MATCH_PARENT);
		listView.setVisibility(View.INVISIBLE);
		this.addView(listView, params);
	}

	public void show() {
		bar.setVisibility(View.GONE);
		listView.setVisibility(View.VISIBLE);
	}

	public void loading() {
		bar.setVisibility(View.VISIBLE);
		listView.setVisibility(View.GONE);
	}

	public LoadMoreListView getListView() {
		return listView;
	}
}
